﻿<?xml version="1.0" standalone="yes"?>
<SqlCommand>
  <xs:schema id="SqlCommand" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="SqlCommand" msdata:IsDataSet="true" msdata:Locale="hu-HU">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="SqlCommand">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Type" type="xs:string" minOccurs="0" />
                <xs:element name="Version" type="xs:string" minOccurs="0" />
                <xs:element name="Select" type="xs:string" minOccurs="0" />
                <xs:element name="Where" type="xs:string" minOccurs="0" />
                <xs:element name="Order" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <SqlCommand>
    <Type>Server</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT Server=@ProcSchema,
      Name=@Name,
      Collation=cast(serverproperty('Collation') as nvarchar(255)),
      Edition=cast(serverproperty('Edition') as nvarchar(255)),
      ProcuctVersion=cast(serverproperty('ProductVersion') as nvarchar(255)),
      ProductLevel=cast(serverproperty('ProductLevel') as nvarchar(255)),
      IsFullTextInstalled=cast(serverproperty('IsFullTextInstalled') as nvarchar(255)),
      IsIntegratedSecurityOnly=cast(serverproperty('IsIntegratedSecurityOnly') as nvarchar(255)),
      IsSingleUser=cast(serverproperty('IsSingleUser') as nvarchar(255)),
      IsSyncWithBackup=cast(serverproperty('IsSyncWithBackup') as nvarchar(255))
    </Select>
  </SqlCommand>

  <SqlCommand>
    <Type>Database</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT
      Server=@ProcSchema,Name=name,
      HasDbAccess=cast(IsNull(HAS_DBACCESS ([name]),0) as bit),
      IsAutoClose=cast(DatabasePropertyEx([name],'IsAutoClose') as bit),
      IsAutoCreateStatistics=cast(DatabasePropertyEx([name],'IsAutoCreateStatistics') as bit),
      IsAutoShrink=cast(DatabasePropertyEx([name],'IsAutoShrink') as bit),
      IsAutoUpdateStatistics=cast(DatabasePropertyEx([name],'IsAutoUpdateStatistics') as bit),
      IsAnsiNullDefault=cast(DatabasePropertyEx([name],'IsAnsiNullDefault') as bit),
      IsAnsiNullsEnabled=cast(DatabasePropertyEx([name],'IsAnsiNullsEnabled') as bit),
      IsAnsiPaddingEnabled=cast(DatabasePropertyEx([name],'IsAnsiPaddingEnabled') as bit),
      IsAnsiWarningsEnabled=cast(DatabasePropertyEx([name],'IsAnsiWarningsEnabled') as bit),
      IsArithmeticAbortEnabled=cast(DatabasePropertyEx([name],'IsArithmeticAbortEnabled') as bit),
      IsNullConcat=cast(DatabasePropertyEx([name],'IsNullConcat') as bit),
      IsNumericRoundAbortEnabled=cast(DatabasePropertyEx([name],'IsNumericRoundAbortEnabled') as bit),
      IsQuotedIdentifiersEnabled=cast(DatabasePropertyEx([name],'IsQuotedIdentifiersEnabled') as bit),
      IsRecursiveTriggersEnabled=cast(DatabasePropertyEx([name],'IsRecursiveTriggersEnabled') as bit),
      IsTornPageDetectionEnabled=cast(DatabasePropertyEx([name],'IsTornPageDetectionEnabled') as bit),
      IsCloseCursorsOnCommitEnabled=cast(DatabasePropertyEx([name],'IsCloseCursorsOnCommitEnabled') as bit),
      IsLocalCursorsDefault=cast(DatabasePropertyEx([name],'IsLocalCursorsDefault') as bit),
      Status=cast(DatabasePropertyEx([name],'Status') as nvarchar(200)),
      Updateability=cast(DatabasePropertyEx([name],'Updateability') as nvarchar(200)),
      Collation=cast(DatabasePropertyEx([name],'Collation') as nvarchar(200)),
      RecoveryOption=cast(DatabasePropertyEx([name],'Recovery') as nvarchar(200)),
      DatabaseVersion=cast(DatabasePropertyEx([name],'Version') as nvarchar(200)),
      DataBaseLevel=cast(cmptlevel as int),
      IsFulltextEnabled=cast(DatabasePropertyEx([name],'IsFulltextEnabled') as bit),
      IsInStandBy=cast(DatabasePropertyEx([name],'IsInStandBy') as bit),
      IsMergePublished=cast(DatabasePropertyEx([name],'IsMergePublished') as bit),
      IsSubscribed=cast(DatabasePropertyEx([name],'IsSubscribed') as bit),
      UserAccess=cast(DatabasePropertyEx([name],'UserAccess') as nvarchar(200))
      FROM master.dbo.sysdatabases
      WHERE name LIKE @Name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>User</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT Name=u.name,
      LoginName= ISNULL(suser_sname(u.sid),N''),
      IsSqlUser = CASE WHEN ISNULL(suser_sname(u.sid),N'') IS NOT NULL THEN 0 ELSE 1 END,
      DefaultSchemaName = u.default_schema_name
      FROM sys.database_principals AS u
      WHERE u.TYPE = 'U'
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>UDT</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=u.name,
      Name=t.name,
      AllowNulls=cast(t.allownulls as bit),
      [Length]=cast(CASE WHEN t2.name IN (N'nchar', N'nvarchar') THEN t.length/2 ELSE t.length END as int),
      [Precision]=cast(isnull(t.prec,0) as int),
      [Scale]=cast(isnull(t.scale,0) as int),
      BaseType=IsNull(t2.name,''),
      DefaultSchema=IsNull(dusers.name,'') ,
      DefaultName=IsNull(def.name,''),
      RuleSchema=IsNull(rusers.name,''),
      RuleName=IsNull(rules.name,'')
      FROM dbo.systypes As t
      JOIN dbo.sysusers As u ON t.uid=u.uid
      JOIN dbo.systypes As t2 ON t.xtype=t2.xusertype
      LEFT JOIN dbo.sysobjects As def ON def.id=t.tdefault
      LEFT JOIN dbo.sysobjects As rules ON rules.id=t.domain
      LEFT JOIN dbo.sysusers As dusers  ON dusers.uid=def.uid
      LEFT JOIN dbo.sysusers As rusers  ON rusers.uid=rules.uid
      WHERE t.xusertype&gt;256
      ORDER BY SchemaName,Name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Table</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(o.uid),
      TableName=o.name,
      TableHasForeignKey=cast(objectpropertyex(o.id,'TableHasForeignKey') as bit),
      TableHasIndex=Cast(Case WHEN (SELECT COUNT(*)
      FROM dbo.sysindexes As i
      WHERE i.id = o.id AND i.indid &gt; 0 and i.indid &lt; 255
      AND INDEXPROPERTY(i.id, i.name, N'IsStatistics') = 0
      AND INDEXPROPERTY(i.id, i.name, N'IsHypothetical') = 0
      AND i.name not in (select o2.name
      FROM dbo.sysobjects As o2 WHERE o2.parent_obj = o.id
      AND OBJECTPROPERTY(o2.id, N'isConstraint') = 1))&gt;0
      THEN 1 ELSE 0 END as bit) ,
      TableHasPrimaryKey=cast(ObjectPropertyEx(o.id,'TableHasPrimaryKey') as bit),
      TableFileGroup=(SELECT TOP 1 FILEGROUP_NAME(groupid) FROM sysindexes As i WHERE i.id=o.id AND (i.indid=0 or i.indid=1)) ,
      TableTextInRowLimit=cast(ObjectPropertyEx(o.id,'TableTextInRowLimit') as bit),
      TableHasUniqueCnst=cast(ObjectPropertyEx(o.id,'TableHasUniqueCnst') as bit),
      TableHasCheckCnst=cast(ObjectPropertyEx(o.id,'TableHasCheckCnst') as bit),
      TableIsPinned=cast(ObjectPropertyEx(o.id,'TableIsPinned') as bit),
      TableFullTextBackgroundUpdateIndexOn=cast(ObjectPropertyEx(o.id,'TableFullTextBackgroundUpdateIndexOn') as bit),
      TextFileGroup=cast(IsNull((SELECT TOP 1 FILEGROUP_NAME(groupid) FROM dbo.sysindexes As i WHERE i.indid=255 AND i.id = (SELECT i2.id FROM dbo.sysindexes As i2 WHERE i2.indid in (0,1) AND i2.id = o.id)),'')  as nvarchar(255))
      FROM dbo.sysobjects As o
      WHERE xtype=N'U' AND cast(ObjectPropertyEx(o.id,'IsMSShipped') as bit)=0
      AND o.name NOT LIKE '#%'
      AND Schema_Name(o.uid) LIKE @ProcSchema
      #_AND o.name NOT LIKE '[_]%'  _#
      AND o.name LIKE @Name
      ORDER BY SchemaName,TableName
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Fields</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT
      SchemaName=Schema_Name((select schema_id from sys.objects as st where c.object_id=st.object_id)),
      TableName=Object_Name(c.object_id),
      Name=c.name, ColId=cast(c.column_id as int),
      DataTypeName=st.name,
      BaseTypeName=bt.name,
      Length=cast(isnull(case when bt.name in (N'nchar', N'nvarchar') then c.max_length/2 else c.max_length end,0) as int),
      [Precision]=cast(isnull(c.precision,0) as int),
      Scale=cast(isnull(c.scale,0) as int),
      AllowsNull=cast(c.is_nullable as bit),
      IsIdentity=cast(is_identity as bit),
      IdentSeed=case when is_identity = 1 then
      CONVERT(nvarchar(40), ident_seed( QuoteName(Schema_Name((select schema_id from sys.objects as st where c.object_id=st.object_id)))+'.'+Object_Name(c.object_id))) else null end ,
      IdentIncr=case when is_identity = 1 then
      CONVERT(nvarchar(40), ident_incr( QuoteName(Schema_Name((select schema_id from sys.objects as st where c.object_id=st.object_id)))+'.'+Object_Name(c.object_id))) else null end ,
      ConstrSchema=case when (c.default_object_id is not null and (cast(objectpropertyex(c.default_object_id, N'IsDefaultCnst') as bit) = 1)) then
      Schema_Name(cast(objectpropertyex(c.default_object_id,'schemaid') as int)) else null end,
      ConstrName=case when (c.default_object_id is not null and (cast(objectpropertyex(c.default_object_id, N'IsDefaultCnst') as bit) = 1)) then
      Object_Name(c.default_object_id) else null end,
      ConstrNameIsGenerated=cast(case when (c.default_object_id is not null and (cast(objectpropertyex(c.default_object_id, N'IsDefaultCnst') as bit) = 1)) then
      isnull((select is_system_named from sys.default_constraints c1 where c1.object_id=c.default_object_id),0) else 0 end as bit),
      DefConstrSchema=case when (c.default_object_id = 0) then null
      when (cast(objectpropertyex(c.default_object_id, N'IsDefaultCnst') as bit) = 1)
      then null
      else Schema_Name(d.schema_id) end,
      DefConstrName=case when (c.default_object_id = 0) then null
      when (cast(objectpropertyex(c.default_object_id, N'IsDefaultCnst') as bit)= 1)
      then null
      else d.name end,
      IsComputed=cast(c.is_computed as bit),
      ComputedText=cast(IsNull((SELECT cm.definition FROM sys.computed_columns As cm WHERE cm.object_id = c.object_id and cm.column_id = c.column_id ),'') as varchar(max)),
      IsIdNotForRepl=convert(bit, ColumnProperty(c.object_id, c.name, N'IsIdNotForRepl')),
      IsFulltextIndexed=convert(bit, ColumnProperty(c.object_id, c.name, N'IsFulltextIndexed')),
      UsesAnsiTrim=IsNull(convert(bit, ColumnProperty(c.object_id, c.name, N'UsesAnsiTrim')),0),
      RoleSchema=case when (c.rule_object_id = 0) then null else Schema_Name(r.schema_id) end,
      RoleName=case when (c.rule_object_id = 0) then null else r.name end,
      Collation=IsNull(c.collation_name,''),
      IsIndexable=IsNull(ColumnProperty(c.object_id, c.name, N'IsIndexable'),0),
      ColType='',
      IsRowGuidCol=cast(ColumnProperty(c.object_id,c.name,N'IsRowGuidCol') as bit)
      FROM sys.all_columns As c
      LEFT JOIN sys.objects As d on d.object_id = c.default_object_id
      LEFT JOIN sys.objects As r on r.object_id = c.rule_object_id
      JOIN sys.types As st on st.user_type_id = c.user_type_id
      JOIN sys.types As bt on bt.system_type_id = c.system_type_id and bt.user_type_id = c.user_type_id
      WHERE cast(ObjectPropertyEx(c.object_id,'IsUserTable') as bit)=1
      AND cast(objectpropertyex(c.object_id,N'IsMSShipped') as bit)=0
      AND schema_name((select schema_id from sys.objects as st where c.object_id=st.object_id)) like @ProcSchema
      #_AND object_name(c.object_id) NOT LIKE '[_]%' _#
      AND object_name(c.object_id) LIKE @Name
      ORDER BY SchemaName,TableName,c.column_id
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Index</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(cast(ObjectPropertyex(i.object_id,'schemaid') as nvarchar(128))),
      TableName=object_name(i.object_id),Name=i.name,
      IndexFillFactor=cast(i.fill_factor as int),
      IsClustered=cast(CASE WHEN i.type = 1 THEN 1 ELSE 0 END as bit),
      IsFullTextKey=cast(indexproperty(i.object_id,i.name,'IsFullTextKey') as bit) ,
      IsPadIndex=cast(i.is_padded as bit),
      IsPageLockAllowed=cast(i.allow_page_locks ^ 1 as bit),
      IsRowLockAllowed=cast(i.allow_row_locks ^ 1 as bit),
      IndexFileGroup=CASE WHEN 'FG'=dsi.type THEN dsi.name ELSE '' END,
      IndexFileGroupIsDefault=ISNULL(dsi.is_default,0),
      IdxCnstIsDisabled=cast(i.is_disabled as bit),
      IdxCnstIsNotTrusted=isnull(cast(ObjectPropertyEx(o.object_id,'CnstIsNotTrusted') as bit),0) ,
      IsUnique=cast(i.is_unique as bit),
      IsPrimaryKey=cast(i.is_primary_key as bit),
      IsConstraint=cast(i.is_unique_constraint as bit),
      NoRecompute=cast( isnull((SELECT no_recompute FROM sys.stats WHERE name=i.name and i.object_id = object_id),0) as bit ),
      IgnoreDupKey=cast(i.[ignore_dup_key] as bit),
      IndId=cast(i.index_id as int),
      NoName=  cast(IsNull((SELECT k.is_system_named FROM sys.key_constraints AS k WHERE k.parent_object_id = i.object_id AND k.unique_index_id = i.index_id),0) as bit) ,
      GeneratedName='',
      IsDisabled=i.is_disabled,
      HasFilter = i.has_filter,
      FilterDefinition = ISNULL(i.filter_definition,''),
      PartitionSchema = CASE WHEN 'PS' = dsi.type THEN dsi.name ELSE '' END,
      IsXmlIndex = CAST(case when i.type=3 then 1 else 0 end AS bit),
      SecondaryXmlIndex = case UPPER(ISNULL(xi.secondary_type,'')) when 'P' then 1 when 'V' then 2 when 'R' then 3 else 0 END,
      PrimaryXmlIndexName = ISNULL((SELECT  name FROM sys.xml_indexes AS x WHERE xi.OBJECT_ID = x.object_id and  xi.using_xml_index_id = x.index_id AND x.using_xml_index_id IS null),'')
      FROM sys.indexes As i
      LEFT OUTER JOIN sys.tables As o ON i.name=o.name
      LEFT OUTER JOIN sys.data_spaces AS dsi ON dsi.data_space_id = i.data_space_id
      LEFT OUTER JOIN sys.data_spaces AS dstbl ON dstbl.data_space_id = o.Filestream_data_space_id and i.index_id  &lt; 2
      LEFT OUTER JOIN sys.xml_indexes AS xi ON xi.object_id = i.object_id AND xi.index_id = i.index_id
      WHERE i.name IS NOT NULL  AND (i.index_id &gt; 0 and i.is_hypothetical = 0)
      AND (cast(ObjectPropertyEx(i.object_id,'IsUserTable') as bit)=1 OR cast(ObjectPropertyEx(i.object_id,'isView') as bit)=1 )
      AND Cast(ObjectPropertyEx(i.object_id,'IsMSShipped') as bit)=0
      #_AND object_name(i.object_id) NOT LIKE '[_]%'  _#
      AND object_name(i.object_id) LIKE @Name
      AND Schema_Name(cast(ObjectPropertyex(i.object_id,'schemaid') as nvarchar(128))) LIKE @ProcSchema
      ORDER BY SchemaName,TableName,IndId
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>IndexKey</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(cast(objectpropertyex(ic.object_id,'SchemaId') as int)),
      TableName=object_name(ic.object_id),
      Name=i.name,
      ColumnName=(SELECT name FROM sys.all_columns as c WHERE c.object_id=ic.object_id AND ic.column_id=c.column_id),
      KeyNo=cast(ic.index_column_id as int),
      IsDescending=cast(is_descending_key as bit),
      IndId=cast(ic.index_id as int),
      IsIncluded=cast(ic.is_included_column as bit)
      FROM sys.index_columns as ic
      JOIN sys.indexes as i ON (ic.column_id > 0 and (ic.key_ordinal > 0 or ic.partition_ordinal = 0)) AND (ic.index_id=CAST(i.index_id AS int) AND ic.object_id=i.object_id)
      WHERE i.index_id>0
      AND (i.name is not null)
      AND (i.index_id > 0 and i.is_hypothetical = 0)
      AND 	(ObjectProperty(i.object_id,'IsUserTable')=1 OR ObjectProperty(i.object_id,'isView')=1)
      AND ObjectProperty(i.object_id,'IsMSShipped')=0
      #_AND object_name(i.object_id) NOT LIKE '[_]%'  _#
      AND object_name(i.object_id) LIKE @Name
      AND Schema_Name(cast(ObjectPropertyex(i.object_id,'schemaid') as nvarchar(128))) LIKE @ProcSchema
      ORDER BY SchemaName,TableName,IndId,KeyNo
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Foreign</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(k.schema_id),
      TableName=Object_Name(k.parent_object_id),
      Name=k.name,
      RSchema=Schema_Name(cast(ObjectPropertyex(k.referenced_object_id,'schemaid') as int)),
      RTableName=Object_Name(k.referenced_object_id),
      FkeyCnstIsDisabled=cast(is_disabled as bit),
      FkeyDeleteCascade = cast(delete_referential_action as bit),
      FkeyUpdateCascade = cast(update_referential_action as bit),
      FkeyCnstIsColumn = cast(ObjectPropertyex( k.object_id, N'CnstIsColumn') as bit),
      FkeyCnstIsNotTrusted=cast(is_not_trusted as bit),
      FkeyCnstIsNotForReplication= cast(is_not_for_replication as bit) ,
      NoName= cast(is_system_named as bit) ,
      GeneratedName=''
      FROM sys.foreign_keys As k
      WHERE cast(ObjectPropertyEx(k.parent_object_id,'IsUserTable') as bit)=1
      AND cast(ObjectProperty(k.parent_object_id,'IsMSShipped') as bit)=0
      #_AND object_name(k.parent_object_id) NOT LIKE '[_]%'  _#
      AND object_name(k.parent_object_id) LIKE @Name
      AND Schema_Name(k.schema_id) LIKE @ProcSchema
      ORDER BY SchemaName,TableName,Name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>ForeignKey</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT
      SchemaName=Schema_Name(cast(ObjectPropertyex(r.constraint_object_id,'schemaid') as int)),
      TableName=Object_Name(r.parent_object_id),
      Name=Object_Name(r.constraint_object_id),
      Fkey=(SELECT [name] from sys.columns where r.parent_column_id = column_id and r.parent_object_id = object_id),
      Rkey=(SELECT [name] from sys.columns where r.referenced_column_id=column_id and r.referenced_object_id=object_id),
      KeyNo=cast(r.constraint_column_id as int)
      FROM sys.foreign_key_columns as r
    </Select>
    <Where>
      WHERE cast(ObjectPropertyex(r.parent_object_id,'IsUserTable') as bit)=1
      AND cast(ObjectPropertyex(r.parent_object_id,'IsMSShipped') as bit)=0
      #_AND Object_Name(r.parent_object_id) NOT LIKE '[_]%'_#
      AND object_name(r.parent_object_id) LIKE @Name
      AND Schema_Name(cast(ObjectPropertyex(r.constraint_object_id,'schemaid') as int)) LIKE @ProcSchema
    </Where>
    <Order> ORDER BY SchemaName,TableName,Name,KeyNo </Order>
  </SqlCommand>
  <SqlCommand>
    <Type>Check</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(schema_id),
      TableName=Object_Name(parent_object_id),
      Name=name,
      Id=object_id,
      NoName=cast(is_system_named as bit),
      CnsIsDisabled=cast(is_disabled as bit),
      CnsIsNotTrusted=cast(is_not_trusted as bit),
      CnsNotForReplication=cast(is_not_for_replication as bit),
      UsesDatabaseCollation=cast(uses_database_collation as bit),
      [Definition]=[Definition]
      FROM sys.check_constraints
      WHERE is_ms_shipped=0
      #_AND Object_Name(parent_object_id) NOT LIKE '[_]%'  _#
      AND Object_Name(parent_object_id) LIKE @Name
      AND Schema_Name(schema_id) LIKE @ProcSchema
      ORDER BY SchemaName,TableName,Id
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Function</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(o.schema_id),
      Name=o.name,
      IsQuotedIdentsOn=cast(ObjectpropertyEx(object_id,'IsQuotedIdentOn') as bit) ,
      IsAnsiNullsOn=cast(ObjectpropertyEx(object_id,'IsAnsiNullsOn') as bit),
      IsSchemaBound=cast(ObjectPropertyEx(object_id,'IsSchemaBound') as bit)
      FROM sys.objects AS o
      WHERE type in ('TF','IF','FN')
      AND Schema_Name(o.schema_id) like @ProcSchema
      AND Is_MS_Shipped=0
      AND name LIKE @Name
      #_AND name NOT LIKE '[_]%' _#
      ORDER BY SchemaName,Name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Procedure</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(o.schema_id),Name=o.name,IsStartup=cast(ObjectProperty(object_id,'ExecIsStartup') as bit),IsQuotedIdentsOn=cast(ObjectProperty(object_id,'IsQuotedIdentOn') as bit),IsAnsiNullsOn=cast(ObjectProperty(object_id,'IsAnsiNullsOn') as bit) FROM sys.objects AS o WHERE type='P'AND Schema_Name(o.schema_id) like @ProcSchema AND  is_ms_shipped=0
      #_AND o.name NOT LIKE '[_]%'  _#
      AND o.name LIKE @Name ORDER BY Schema_Name(o.schema_id),o.name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>View</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=Schema_Name(o.schema_id),Name=o.name,
      IsQuotedIdentsOn=cast(ObjectProperty(object_id,'IsQuotedIdentOn') as bit) ,
      IsAnsiNullsOn=cast(ObjectProperty(object_id,'IsAnsiNullsOn') as bit) ,
      IsSchemaBound = cast(with_check_option as bit) /*,
      IsReplicated=cast(is_replicated as bit) ,
      HasReplicationFilter=cast(has_replication_filter as bit),
      HasOpaqueMetadata=cast(has_opaque_metadata as bit),
      HasUncheckedAssemblyData=cast(has_unchecked_assembly_data as bit),
      IsDateCorrelationView=cast(is_date_correlation_view as bit)*/
      FROM sys.views AS o
      WHERE Schema_Name(o.schema_id) like @ProcSchema
      AND is_ms_shipped=0
      AND name LIKE @Name
      #_AND name NOT LIKE '[_]%'  _#
      ORDER BY SchemaName,Name
    </Select>
  </SqlCommand>
  <SqlCommand>
    <Type>Trigger</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT
      SchemaName=Schema_Name(cast(objectpropertyex(object_id,'SchemaId') as int)),
      Name=name,
      IsQuotedIdentsOn=cast(ObjectProperty(object_id,'IsQuotedIdentOn') as bit) ,
      IsAnsiNullsOn=cast(ObjectProperty(object_id,'IsAnsiNullsOn') as bit) ,
      IsFirstDeleteTrigger=cast(ObjectProperty(object_id,'ExecIsFirstDeleteTrigger') as bit) ,
      IsFirstInsertTrigger=cast(ObjectProperty(object_id,'ExecIsFirstInsertTrigger') as bit) ,
      IsFirstUpdateTrigger=cast(ObjectProperty(object_id,'ExecIsFirstUpdateTrigger') as bit) ,
      IsLastDeleteTrigger=cast(ObjectProperty(object_id,'ExecIsLastDeleteTrigger') as bit) ,
      IsLastInsertTrigger=cast(ObjectProperty(object_id,'ExecIsLastInsertTrigger') as bit) ,
      IsLastUpdateTrigger=cast(ObjectProperty(object_id,'ExecIsLastUpdateTrigger') as bit) ,
      TriggerIsDisabled=cast(is_disabled as bit)
      --IsDatabaseTrigger=parent_class,
      --TriggerType=type,
      FROM sys.triggers
      WHERE is_ms_shipped=0
      AND Schema_Name(cast(objectpropertyex(object_id,'SchemaId') as int)) like @ProcSchema
      AND name LIKE @Name
      #_AND name NOT LIKE '[_]%'_#
      ORDER BY SchemaName,Name
    </Select>
  </SqlCommand>

  <SqlCommand>
    <Type>Rule</Type>
    <Version>Sql2008</Version>
    <Select>SELECT SchemaName=Schema_Name(o.uid),Name=o.name FROM dbo.sysobjects o WHERE xtype='R' order by SchemaName,Name</Select>
  </SqlCommand>

  <SqlCommand>
    <Type>Default</Type>
    <Version>Sql2008</Version>
    <Select>SELECT SchemaName=Schema_Name(o.uid),Name=o.name FROM dbo.sysobjects As o WHERE xtype='D' AND OBJECTPROPERTY(o.id, N'IsDefault') = 1 ORDER BY SchemaName,Name</Select>
  </SqlCommand>

  <SqlCommand>
    <Type>DefaultCnst</Type>
    <Version>Sql2008</Version>
    <Select>
      select SchemaName=SCHEMA_NAME (schema_id),Name,Definition=[definition]
      from sys.default_constraints
      ORDER BY SchemaName,Name
    </Select>
  </SqlCommand>

  <SqlCommand>
    <Type>ComputedColumns</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT [Schema]=Schema_Name(o.uid),
      TableName=o.name,ColumnName=c.name,c.colid,co.text
      FROM dbo.sysobjects As o
      JOIN dbo.syscolumns As c on c.id=o.id
      JOIN dbo.syscomments As co on co.id=o.id AND co.number = c.colid
      WHERE c.iscomputed=1 AND o.xtype='U'
      #_ AND o.name NOT LIKE '[_]%' _#
    </Select>
    <Order> ORDER BY [Schema],TableName,ColumnName,co.colid</Order>
  </SqlCommand>

  <SqlCommand>
    <Type>FileGroup</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT FileGroupName=groupname,
      IsReadOnly=FILEGROUPPROPERTY(groupname,'IsReadOnly')
      IsDefault=FILEGROUPPROPERTY(groupname,'IsDefault')
      FROM dbo.sysfilegroups
    </Select>
    <Order> ORDER BY FileGroupName</Order>
  </SqlCommand>

  <SqlCommand>
    <Type>Details</Type>
    <Version>Sql2008</Version>
    <Select>
      SELECT SchemaName=SCHEMA_NAME(o.schema_id),Name=OBJECT_NAME(m.OBJECT_ID),
      ObjectType=0,
      Text = CASE cast(isnull(objectpropertyex(m.object_id,'IsEncrypted'),0) as bit) WHEN 0 then definition ELSE '-- encrypted text' end
      FROM sys.all_sql_modules AS m
      JOIN sys.objects AS o ON o.object_id = m.object_id
      WHERE o.is_ms_shipped = 0
    </Select>
  </SqlCommand>
  
  

</SqlCommand>
